package com.hsq.ndmall.coupon.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiOperation;
import com.hsq.ndmall.coupon.entity.FlashPromotionSessionEntity;
import com.hsq.ndmall.coupon.service.FlashPromotionSessionService;
import com.hsq.ndmall.common.utils.PageUtils;
import com.hsq.ndmall.common.utils.R;
import io.swagger.annotations.Api;


/**
 * 限时购场次表
 *
 * @author Mr.Huang
 * @email 1607922199@qq.com
 * @date 2021-08-11 21:49:36
 */
@Api(tags = "FlashPromotionSessionController", description = "限时购场次表服务")
@RestController
@RequestMapping("coupon/flashpromotionsession")
public class FlashPromotionSessionController {
    @Autowired
    private FlashPromotionSessionService flashPromotionSessionService;

    /**
     * 列表
     */
    @GetMapping("/list")
    //@RequiresPermissions("coupon:flashpromotionsession:list")
    @ApiOperation("获取所有限时购场次表信息")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = flashPromotionSessionService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("coupon:flashpromotionsession:info")
    @ApiOperation("获取指定id的限时购场次表详情")
    public R info(@PathVariable("id") Long id){
		FlashPromotionSessionEntity flashPromotionSession = flashPromotionSessionService.getById(id);

        return R.ok().put("flashPromotionSession", flashPromotionSession);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation("添加限时购场次表信息")
    //@RequiresPermissions("coupon:flashpromotionsession:save")
    public R save(@RequestBody FlashPromotionSessionEntity flashPromotionSession){
		flashPromotionSessionService.save(flashPromotionSession);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @ApiOperation("更新指定id限时购场次表信息")
    //@RequiresPermissions("coupon:flashpromotionsession:update")
    public R update(@RequestBody FlashPromotionSessionEntity flashPromotionSession){
		flashPromotionSessionService.updateById(flashPromotionSession);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    @ApiOperation("删除指定id限时购场次表信息")
    //@RequiresPermissions("coupon:flashpromotionsession:delete")
    public R delete(@RequestBody Long[] ids){
		flashPromotionSessionService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
